import axios from '../plugins/axios';
//服务 就是一个异步函数，返回 Promise
export const queryHome = async (params) => {
    return axios({
        url: '/mock/home',
        params: params || {_page: 1, _limit: 30}
    })
};

export const queryFollow = async (params) => {
    return axios({
        url: '/mock/follow',
        params: params || {_page: 1, _limit: 20}
    })
};

export const queryColumn = async (params) => {
    return axios({
        url: '/mock/column',
        params: params || {_page: 1, _limit: 10}
    })
};

export const queryBanner = async (params) => {
    return axios({
        url: '/mock/banner',
        params: params || {_page: 1, _limit: 3}
    })
};

export const queryDetail = async ({id, apiname}) => {
    return axios({
        url: `/mock/${apiname}/${id}`
    })
};

export const queryAll = async (arr) => {
    return axios.all(arr).then(axios.spread((banner, home)=>{
        return {home, banner}
    }))
};